"""
name: Hello Wold
version: 1.0
"""
from PyQt5.QtWidgets import (QApplication, QWidget, QPushButton, 
                             QLabel, QHBoxLayout)

class MyWidget(QWidget):
    def __init__(self):
        super().__init__()
        self.resize(500, 250)
        self.setWindowTitle('Hello World')
        self.lable = QLabel('按钮示例', self) 
        self.button = QPushButton('点我啊', self)  
        self.button.clicked.connect(self.close)
        self.hbox = QHBoxLayout(self)  # 创建一个水平布局对象
        # 将标签（lable）和按钮（button）这两个组件添加到 hbox 中
        self.hbox.addWidget(self.lable)
        self.hbox.addWidget(self.button)
        self.setLayout(self.hbox)  # 将hbox设置为widget的布局

app = QApplication([])
widget = MyWidget()  
widget.show() 
app.exec_()  
